package com.css.fxfzypg.modules.suggestinfo.analysis.annualrisk.controller;

import com.css.fxfzypg.base.response.RestResponse;
import com.css.fxfzypg.modules.suggestinfo.analysis.annualrisk.repository.entity.AnnualRiskEntity;
import com.css.fxfzypg.modules.suggestinfo.analysis.annualrisk.service.AnnualRiskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/annualRisk")
@Slf4j
public class AnnualRiskController {

    @Autowired
    AnnualRiskService annualRiskService;

    @PostMapping("/saveAnnualRisk")
    public RestResponse save(@RequestBody AnnualRiskEntity annualRiskEntity) {
        RestResponse response = null;
        try{
            boolean res = annualRiskService.save(annualRiskEntity);
            if(res){
                response = RestResponse.succeed("保存成功!");
                response.setMessage("保存成功!");
            }else {
                response = RestResponse.fail("保存失败!");
            }
        }catch (Exception e){
            String errormessage = "保存失败!";
            log.error(errormessage,e);
            response=RestResponse.fail(errormessage);
        }
        return response;
    }

    /**
     * 获取年度风险应对策略建议详情页(对策建议分析模块)
     * @param params
     * @return
     */
   /* @GetMapping("/getAnnualRiskData")
    public RestResponse getAnnualRiskData(ParamsVo params) {
        RestResponse response = null;
        try{
            AnnualRiskEntity annualRiskEntity = annualRiskService.getAnnualRiskData(params);
            response = RestResponse.succeed(annualRiskEntity);
            response.setMessage("获取详情页数据成功");
        }catch (Exception e){
            log.error("获取详情页数据失败!",e);
            response=RestResponse.fail("获取详情页数据失败!");
        }
        return response;
    }*/


}
